<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>CruiseControl.NET : Using CruiseControl.NET with Ant</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            CruiseControl.NET : Using CruiseControl.NET with Ant
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Oct 31, 2005 by <font color="#0050B2">mroberts</font>.
				    </div>

				    <p>The following sections show you how to setup CruiseControl.NET to build a project using <a href="http://ant.apache.org/">Ant</a> as its build tool. This page was written testing against Ant version 1.6.5 .</p>

<h2><a name="UsingCruiseControl.NETwithAnt-SettinguptheBuildServer"></a>Setting up the Build Server</h2>

<p>At the present time, CruiseControl.NET does not have an Ant-specific task but using the <a href="Executable Task.html" title="Executable Task"><tt>&lt;exec&gt;</tt></a> task is sufficient. An example is as below:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">&lt;exec 
    executable=<span class="code-quote">"ant.bat"</span> 
    buildArgs=<span class="code-quote">"-logger org.apache.tools.ant.XmlLogger -logfile build_log.xml build"</span> 
/&gt;</pre>
</div></div>

<p>This example presumes the following:</p>
<ul>
	<li>ant.bat is in your path</li>
	<li>Your <a href="Project Configuration Block.html#ProjectConfigurationBlock-workingDirectory">project working directory</a> contains your <tt>build.xml</tt> ant script, and that is also the directory you would normally run Ant in.</li>
</ul>


<p>If either of these are not true adapt your call to <tt>&lt;exec&gt;</tt> as necessary.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>If you use the ant.bat file to call Ant, make sure you edit the file to return to correct exit code. A simple way to do this is too add the following line to the end of the ant.bat file:
<ul>
	<li><tt>exit %ERRORLEVEL%</tt></li>
</ul>
</td></tr></table></div>

<p>Assuming you are using Ant's XML output (as the example above does) you'll also need to merge the xml output. A typical example is as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;publishers&gt;</span>
    <span class="code-tag">&lt;merge&gt;</span>
        <span class="code-tag">&lt;files&gt;</span>
            <span class="code-tag">&lt;file&gt;</span>build_log.xml<span class="code-tag">&lt;/file&gt;</span>
        <span class="code-tag">&lt;/files&gt;</span>
    <span class="code-tag">&lt;/merge&gt;</span>
    <span class="code-tag">&lt;xmllogger /&gt;</span>
<span class="code-tag">&lt;/publishers&gt;</span></pre>
</div></div>

<h2><a name="UsingCruiseControl.NETwithAnt-SettinguptheDashboard"></a>Setting up the Dashboard</h2>

<p>Assuming you are using Ant's XML output you can setup a <a href="XSL Report Build Plugin.html" title="XSL Report Build Plugin">XSL Report Build Plugin</a>. An example for your <tt>dashboard.config</tt> is as below:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;xslReportBuildPlugin description=<span class="code-quote">"Ant Output"</span> actionName=<span class="code-quote">"AntBuildReport"</span> xslFileName=<span class="code-quote">"xsl\ant.xsl"</span> /&gt;</span></pre>
</div></div>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 29, 2009 20:59</font></td>
		    </tr>
	    </table>
    </body>
</html>